<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<%@ taglib prefix="his_fns" uri="/WEB-INF/tlds/his_fns.tld" %>
<script type="text/javascript">
  //弹出右
  $("#addClinic").on('click',function(){
    hideShowTableTd('contentTable','5,6','2');
    $("#LeftDiv").attr("class","main-content col-lg-8");
    $("#RightDiv").show('normal');
    return loadDiv('rigthCenterDiv','${ctx}/nurse/bedRec/form');
  });

  //弹出右 修改
  function rightUpdate(id){
    hideShowTableTd('contentTable','5,6','2');
    $("#LeftDiv").attr("class","main-content col-lg-8");
    $("#RightDiv").show('normal');
    return loadDiv('rigthCenterDiv','${ctx}/nurse/bedRec/form?id='+id);
  }
  function openRegister(id){
    register=layer.open({
      title:'换床',
      type: 1,
      area: ['25%', '25%'],
      content: $("#regResult"),
      btn: ['确定', '取消'],
      yes:function(index,layero){
        butType(id);
      }
    });
  }
  function page(n,s){
      $("#pageNo").val(n);
      $("#pageSize").val(s);
      $("#searchForm").submit();
      return false;
  }
  //换床
  function butType(id){
    var bedNoNew = $("#bedNoNew").val()
    var bedLabelNew = $("#bedLabelNew").val()
    $.ajax({
      type: "POST",
      data:$("#inputForm").serialize(),
      url: "${ctx}/nurse/bedRec/umbetten?id="+id+"&bedNoNew="+bedNoNew+"&bedLabelNew="+bedLabelNew,
      dataType: "json",
      success: function (data) {
        if(data.code=="success"){
          toastr.success(data.data);
        }else{
          toastr.error(data.data);
        }
        layer.close(register);
        loadDiv('nurseIndexDiv','${ctx}/nurse/bedRec/formList')
      },
      error: function (data) {
        toastr.error('网络连接错误,请检查网络');
      }
    });
  }
</script>
<div class="app">
  <section class="layout">
    <section class="main-content col-lg-12" id="LeftDiv">
      <div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
          <ul class="nav nav-tabs">
            <li class="active">
              <a href="#" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/bedRec/formList')">床位维护</a>
            </li>
          </ul>
          <section class="panel panel-default">
            <div class="panel-body">
              <div class="form-group">
                <input  class="btn btn-primary" type="button" value="新增" id="addClinic"/>
                <input  class="btn btn-primary" type="button" value="包床" onclick="loadDiv('nurseIndexDiv','${ctx}/nurse/bedRec/bedOccupyList')"/>
              </div>
              <div class="table-responsive no-border">
            <form id="searchForm" onsubmit="return loadDivForm('mainCenterDiv','searchForm','${ctx}/nurse/bedRec/formList');" method="post" class="form-inline">
                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            </form>
                <table id="contentTable" class="table table-bordered table-striped mg-t datatable">
                  <thead>
                  <tr>
                    <th>床号</th>
                    <th>床标号</th>
                    <th>房间</th>
                    <th>男/女</th>
                    <th>等级</th>
                    <th>空调等级</th>
                    <th>类型</th>
                    <th>空床</th>
                    <th>操作</th>
                  </tr>
                  </thead>
                  <tbody>
                  <c:forEach items="${page.list}" var="bedRec">
                    <tr>
                      <td> ${bedRec.bedNo}</td>
                      <td> ${bedRec.bedLabel}</td>
                      <td> ${bedRec.roomNo}</td>
                      <td> ${fns:getDictLabel(bedRec.bedSexType,"SEX_DICT" ,"通用" )}</td>
                      <td> ${his_fns:getClinicName(bedRec.bedGrade)}</td>
                      <td> ${his_fns:getClinicName(bedRec.airconditionClass)}</td>
                      <td> ${fns:getDictLabel(bedRec.bedApprovedType,"BED_APPROVED_TYPE_DICT" ,"" )}</td>
                      <td> ${fns:getDictLabel(bedRec.bedStatus,"YES_NO" ,"" )}</td>
                      <td>
                        <a href="#" onclick = rightUpdate('${bedRec.id}') id="updateClinic" class="btn btn-success btn-xs">修改</a>
                        <c:if test="${bedRec.visitId != null}">
                          <a href="#" onclick = openRegister('${bedRec.id}') id="" class="btn btn-success btn-xs">换床</a>
                        </c:if>
                        <c:if test="${bedRec.bedStatus==1 || bedRec.bedStatus eq '1'}">

                          <a href="#"  class="applyBt btn btn-danger btn-xs" onclick="confirmExtend('确认要删除床位吗？',function(){delLoad('mainCenterDiv','${ctx}/nurse/bedRec/delete?id=${bedRec.id}','${ctx}/nurse/bedRec/formList')})">删除</a>
                        </c:if>

                      </td>
                    </tr>
                  </c:forEach>
                  </tbody>
                </table>
                <div class="pagination">${page}</div>
              </div>
            </div>
          </section>
        </div>
      </div>
    </section>

    <%--右侧诊疗项目列表--%>
    <section class="main-content col-lg-4" style="display: none" id="RightDiv">
      <div class="content-wrap" id="rigthCenterDiv">
      </div>
    </section>
    <input type="hidden" id="patientId" value="${outpTreatRec.patientId}">
    <input type="hidden" id="clinicId" value="${outpTreatRec.clinicId}">
  </section>
  <div class="col-md-8 " id="regResult" style="display: none">
    <section class="panel panel-primary no-b">
      <div class="list-group" id="reg">
        <div class="col-lg-12">
          <form id="inputForm"  method="post" class="form-horizontal">
            <div class="form-group">
              <label class="col-sm-4 control-label">新床位号：</label>
              <div class="col-sm-8">
                <input id="bedNoNew" htmlEscape="false" class="form-control"  maxlength="32"/>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-4 control-label">新床标号：</label>
              <div class="col-sm-8">
                <input id="bedLabelNew" htmlEscape="false" class="form-control"  maxlength="32"/>
              </div>
            </div>
          </form>
        </div>
      </div>
    </section>
  </div>

</div>
